cmake_minimum_required(VERSION 3.20)

project(test)

set(CMAKE_CXX_STANDARD 17)

option(USE_CUSTOM_MATH_LIBRARY "Using my own Math library?" ON) 

# 方式1:使用configure.h
set(CONFIGURE_FILE_DIR "configure_file")
configure_file(configure.h.in ${CONFIGURE_FILE_DIR}/configure.h)

if(USE_CUSTOM_MATH_LIBRARY)
    add_subdirectory(./Math)
    list(APPEND LINK_LIBRARIES math)
endif()

add_executable(test "main.cpp")
# 方式2:添加编译选项
# if(USE_CUSTOM_MATH_LIBRARY)
#     target_compile_definitions(test PRIVATE USE_CUSTOM_MATH_LIBRARY)
# endif()

# 包含configure_file配置目录
target_include_directories(test PRIVATE ${CMAKE_BINARY_DIR}/${CONFIGURE_FILE_DIR})
message("-----------${CMAKE_BINARY_DIR}/${CONFIGURE_FILE_DIR}-")
target_link_libraries(test PRIVATE ${LINK_LIBRARIES})
